<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let body = document.querySelector('body');
        let persons = [
            { "username": "xiaoming1", "password": "1111" },
            { "username": "xiaoming2", "password": "222" },
            { "username": "xiaoming3", "password": "33333" }
        ]
        let user = { username: "admin1", password: "12345" }
        let a = persons.find(item => user.username === item.username);
        if (a) {
            body.innerHTML = `用户名已注册`;
        } else {
            persons.push(user)
            body.innerHTML = `注册成功`;
        }
        console.log(persons);
    </script>
</body>

</html>